Superclass modifying recipes#3
Conversation
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByPackage.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByType.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverride.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessarySuperCalls.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/util/MethodStubCreator.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethodsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByPackage.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByType.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/util/MethodStubCreator.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethodsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethods.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeVisitor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverride.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/util/MethodStubCreator.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/AddMissingAbstractMethodsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
|
👋 Any feedback on this? |
|
I'll try to get this in with a first 0.0.1 release tomorrow, but haven't found the time to go over it yet. 🙏🏻 |
src/main/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverride.java
Show resolved
Hide resolved
| targetSupertypeName: "io.dropwizard.hibernate.AbstractDAO" | ||
| - org.openrewrite.java.dropwizard.method.ChangeSuperType: | ||
| targetClass: "io.dropwizard.hibernate.AbstractDAO" | ||
| newSuperclass: "ee.taltech.example.AbstractJpaDAO" # Custom class; from helper library |
There was a problem hiding this comment.
I'm not seeing any reference to this one; might that be internal to what you're developing there?
There was a problem hiding this comment.
I also have some general questions regarding the migrations, basically how do we want to add new files like Security Configuration or helper classes - there are a couple of ways we could go about it 1) We can add files via recipes like this - essentially would work, but 1) not good for multi-module projects 2) we do not know where to put those files 3) We lose the type information and these can't really be operated on. The other way is a helper library, where we could put those files, like SecurityConfiguration, a DAO helper class - would you be open to this idea? Any alternative are welcome as well
Essentially I wanted to discuss this, eg. the dropwizard-hibernate library gives a DAO superclass basically - the dropwizard-hibernate .jar itself is riddled with transitive dependencies that bring much of other dw dependencies also in. To get rid of as much of the preexisting dropwizard dependencies themselves I basically isolated the DAO class (with some modifications and put it to a helper library) - I was wondering if that is an approach that is valid here or no
There was a problem hiding this comment.
Understandable that you'd want to trim that down quite a bit, especially in house. For the recipes we offer here I think it might be best not to make any surprising code changes for folks, so I've commented out this step for now so we can get the rest of the changes in.
| spec.parser(JavaParser.fromJavaVersion().classpath("argparse4j", "spring-boot")), | ||
| java( | ||
| """ | ||
| import net.sourceforge.argparse4j.impl.Arguments; | ||
| import net.sourceforge.argparse4j.inf.Subparser; | ||
| import org.springframework.boot.CommandLineRunner; | ||
|
|
||
| public class RenderCommand implements CommandLineRunner { | ||
| @Override | ||
| public void configure(Subparser subparser) { |
There was a problem hiding this comment.
This is a bit of an odd mix of classes used here: it seems to test that halfway through the migration we can clear out an override. Would it not make more sens to have a unit test for the full declarative recipe verify that a fully Dropwizard input is converted to the expected Spring Boot equivalent?
There was a problem hiding this comment.
The first class has an invalid Override method, the second checks that it is removed, I took the example test case from my example dw service repository, it can be repurposed though, what do you suggest?
| import static org.openrewrite.java.tree.TypeUtils.asFullyQualified; | ||
| import static org.openrewrite.java.tree.TypeUtils.isAssignableTo; | ||
|
|
||
| public class AddMissingAbstractMethods extends Recipe { |
There was a problem hiding this comment.
Similarly, and optionally, we already have AddMissingMethodImplementation, which is a little more explicit in it's use, but then saves us having to maintain two recipes for similar functionality. Please let me know your thoughts!
There was a problem hiding this comment.
Yeah, I think I made this recipe before the other one existed, I wanted to make a recipe that can handle all kinds of type changes for different migration scenarios - For more of the overall context; I ran into an issue where entire method signatures change here. I realized that it's really a really a lot of work to start reworking existing methods into new forms, and much simpler to add scaffolding here - so I focused on the quality of life aspect here to automate is as much as I can. I didn't find a really good way of doing so though; I initially kinda hoped that I could just get the method information from the superclasses and kinda reput it into the classes that do the implementation, but that approach did not work, no convenient way to make the Method back into MethodDeclaration form - so I resorted to manually parsing parameters here. Ultimately, its your guys call here how you want to maintain this stuff.
There was a problem hiding this comment.
I don't think this would necessarily interfere with the other recipe, as ideally this could be turned on/off at will, but I understand the maintenance concerns - so your call here
There was a problem hiding this comment.
I've removed the AddAbstractMethods from the PR here, still waiting for feedback on the other stuff
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByPackage.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/dropwizard/method/RemoveSuperTypeByPackage.java
Outdated
Show resolved
Hide resolved
|
Did a first pass through, but more review / polish is needed before we can confidently merge this in. From my point of view some opportunities to reuse existing recipes were missed, which then leads to (not exact) duplication. As long term maintainer of these recipes I think it'd be good to reduce that duplication where we can, as we'd have to otherwise keep up functional copies whenever we make internal changes. Let me know if you'd be open to making those changes still! |
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/ChangeSuperTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/dropwizard/method/RemoveUnnecessaryOverrideTest.java
Show resolved
Hide resolved
timtebeek
left a comment
There was a problem hiding this comment.
Thanks again for the continued work here @Fossur , and the patience with the reviews. I've taken some shortcuts to be able to get this in right now, be stripping out any (up to this point) unnecessary steps such that there's less to review and maintain. I hope you agree!
|
Also: let me know when you'd consider the recipes here fit for a v0.0.1, and then we'll push that out and add it to the docs. 🙏🏻 |
This has recipes to update/remove various supertypes basically. A big part of this is a recipe that can add method stubs when changing classes. Basically it also has various cleanup method and visitors to maintain type consistency after removing/updating methods - I did want it to be as generalizable as possible to also aid in other migrations potentially
Anything in particular you'd like reviewers to focus on?
If there are cleaner ways of adding the methods, doing various type checks, then I would really be open to it. This is a big PR - so take your time - it made sense to bundle them because they are all somewhat related.
Anyone you would like to review specifically?
@timtebeek
Any additional context
I also have some general questions regarding the migrations, basically how do we want to add new files like Security Configuration or helper classes - there are a couple of ways we could go about it 1) We can add files via recipes like this - essentially would work, but 1) not good for multi-module projects 2) we do not know where to put those files 3) We lose the type information and these can't really be operated on. The other way is a helper library, where we could put those files, like SecurityConfiguration, a DAO helper class - would you be open to this idea? Any alternative are welcome as well
Checklist